package com.dandelion.framework.exceptions;


import com.dandelion.framework.enums.CodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * 服务异常
 *
 * @author 77088
 * @date 2022/02/16
 */

@Slf4j
@Data
@EqualsAndHashCode(callSuper = true)
public class ServerException extends RuntimeException {

    private int code;

    private String msg;

    public ServerException(int code) {
        this.code = code;
    }

    public ServerException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public ServerException(CodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
        this.msg = codeEnum.getMsg();
    }

}
